from appium import webdriver
from time import sleep
from appium.webdriver.common.appiumby import By
# 进入界面
# 定义字典
desired_caps = {}# {}定义空字典
desired_caps['platformName']='Android'
desired_caps['platformVersion'] = '7'
desired_caps['deviceName'] = '127.0.0.1:62001'
desired_caps['app'] = r'E:\nmon\apk\110_2039d6385f1dd97e7a399ecb5badcad4.apk' # pc端的apk包所在的路径
desired_caps['appPackage'] = r'com.baidu.homework'
desired_caps['appActivity'] = r'com.baidu.homework.activity.init.InitActivity'
desired_caps['noReset'] = False# 运行过程中是否重置

# 用到的代码：pm查看package，aapt查看activity

driver = webdriver.Remote('http://127.0.0.1:4723/wd/hub',desired_caps)
driver.implicitly_wait(10)
sleep(2)
# 进入界面，点击同意
driver.find_element(By.ID,'com.baidu.homework:id/tv_agree').click()
sleep(2)
# 选择已经满14岁
driver.find_element(By.ID,'com.baidu.homework:id/iknow_alert_dialog_button2').click()


